
#ifndef STUDIO_FILE_H
#define STUDIO_FILE_H

#include "studio_macros.h"

class studio_file
{
  public:
  public:
    /// <summary>
    /// 读取文件内容
    /// </summary>
    /// <param name="u8path">文件路径</param>
    /// <param name="content">内容接受对象</param>
    /// <param name="offset">偏移位置</param>
    /// <param name="len">预定读取大小,SIZE_MAX 为默认全读取</param>
    /// <returns>实际读取大小</returns>
    static size_t read(const std::string &u8path, std::string &content, const size_t &offset = 0, const size_t &len = SIZE_MAX);

    static size_t read(const std::string &u8path, unsigned char **content, const size_t &offset = 0, const size_t &len = SIZE_MAX);

    static bool read(const std::string &u8path, std::vector<std::string> &lines);

    static size_t size(const std::string &u8path);

    /// <summary>
    /// 将内容写入文件
    /// </summary>
    /// <param name="u8path"></param>
    /// <param name="content"></param>
    /// <returns></returns>
    static size_t write(const std::string &u8path, const std::string &content);

    static size_t write(const std::string &u8path, const std::vector<std::string> &lines);

    /// <summary>
    /// 写入一行输入到字符串
    /// </summary>
    /// <param name="logFilePath"></param>
    /// <param name="data"></param>
    /// <returns></returns>
    bool writeLine(const std::string &logFilePath, const std::string &data);

    /// <summary>
    /// 读取一行内容
    /// </summary>
    std::string readLine(const std::string &logFilePath);

    studio_file() = default;
    ~studio_file() = default;
};

#endif  // STUDIO_FILE_H